# 这是68个关键点模型训练
import os
import dlib

current_path = os.getcwd()#获取当前工作路径
#print (current_path)
faces_path = 'F:/dlib-master/tools/imglab/build/Release'
#print (faces_path)

# 训练部分
# 参数设置
options = dlib.shape_predictor_training_options()
options.oversampling_amount = 300
options.nu = 0.5
options.tree_depth = 2
options.be_verbose = True

#导入打好了标签的xml文件
training_xml_path = os.path.join(faces_path, "zx_2.xml")
# # 进行训练，训练好的模型将保存为predictor.dat
# dlib.train_shape_predictor(training_xml_path, "images_facechaoxiang.dat", options)
# 打印在训练集中的准确率
print("Training accuracy:{0}".format(dlib.test_shape_predictor(training_xml_path, "shape_predictor_68_face_landmarks.dat")))


# #导入测试集的xml文件
testing_xml_path = os.path.join(faces_path,"images_face2.xml")
# #打印在测试集中的准确率
print("Testing accuracy:{0}".format(dlib.test_shape_predictor(testing_xml_path, "images_facechaoxiang.dat")))
